package com.qys.livesMall.shop.service.impl;

import com.qys.livesMall.common.utils.DateUtils;
import com.qys.livesMall.shop.modal.dto.PurchaseAccountUse;
import com.qys.livesMall.shop.modal.entity.ShopPurchaseAccountRecord;
import com.qys.livesMall.shop.mapper.ShopPurchaseAccountRecordMapper;
import com.qys.livesMall.shop.service.ShopPurchaseAccountRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 采购额度使用记录 服务实现类
 * </p>
 *
 * @author
 * @since 2023-09-15
 */
@Service
public class ShopPurchaseAccountRecordServiceImpl extends ServiceImpl<ShopPurchaseAccountRecordMapper, ShopPurchaseAccountRecord> implements ShopPurchaseAccountRecordService {

    @Override
    public void add(PurchaseAccountUse use) {
        ShopPurchaseAccountRecord record=new ShopPurchaseAccountRecord();
        record.setShopId(use.getShopId());
        record.setAccountId(use.getAccountId());
        record.setType(use.getType());
        record.setUseAmount(use.getUseAmount());
        record.setAfterAmount(use.getAfter());
        record.setUseDate(DateUtils.dateNow());
        record.setCreateDate(LocalDateTime.now());
        save(record);
    }
}
